<?php

$subject = "hello21_test"; 
$test=preg_replace('#[^0-9_A-Z]#', '', $subject);
echo $test ;
 
 ?>